#!/bin/sh
nodes=("10.10.99.114" "10.10.99.113" "10.10.99.118" "10.10.99.119" 
	"10.10.99.103" "10.10.99.108" "10.10.99.109" "10.10.99.105")

nodenum=8;

case $1 in 
#send cmd to nodes e.g. ./nodes.sh cmd "umount /nfs"
cmd)
	loop=0
	while [ $loop -lt $nodenum ]
	do
		ssh ${nodes[$loop]} $2&
		if [ $? != 0 ]
		then
			echo "command $2 failed. loop: $loop exit."
			exit
		fi
		loop=`expr $loop + 1`

	done
	;;

#./nodes.sh copy src des
copy)	
	
	loop=0
	while [ $loop -lt $nodenum ]
	do
		 scp -r $2 ${nodes[$loop]}:$3
	         if [ $? != 0 ]
		 then
			echo "command copy file loop: $loop exit."
			exit
		 fi

		loop=`expr $loop + 1`
	done
	;;
#sys)
#		
#	loop=4
#	while [ $loop -lt $nodenum ]
#	do
#		scp  /boot/System.map 	${nodes[$loop]}:/boot
#		scp  /boot/System.map-2.6.9-prep-export ${nodes[$loop]}:/boot
#        	scp  /boot/vmlinuz-2.6.9-prep-export ${nodes[$loop]}:/boot
#		scp  /boot/initrd-2.6.9-prep-export.img  ${nodes[$loop]}:/boot
#		scp  /boot/grub/grub.conf  ${nodes[$loop]}:/boot/grub
#		ssh ${nodes[$loop]} 'cd /lib/modules && ln -s /lib/modules/2.6.9-42.ELsmp  2.6.9-prep-export'
#		loop=`expr $loop + 1`
#	done
#	;;
esac

